package com.jvm.methodarea;

/**
 * ConstantPoolDemo..
 *
 * -XX:+PrintStringTableStatistics
 *
 *  -XX:+PrintGCDetails
 * @author Lizhong
 * @date 2020/8/26
 */
public class ConstantPoolDemo {
    public static void main(String[] args) {
        String s = "l";
        StringBuilder stringBuilder= new StringBuilder();
        for (int i = 0; i < 1000000; i++) {
            // s += i;
            stringBuilder.append(s);
            stringBuilder.append(i);
            // 将每个对象链接 到常量池
             s = stringBuilder.toString();
             // 导致方法区爆满
            String intern = s.intern();

        }

    }
}
